<html>
<head><meta charset="utf-8"><title>Cross crate find usages seems to be broken? · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Cross.20crate.20find.20usages.20seems.20to.20be.20broken.3F.html">Cross crate find usages seems to be broken?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="229484749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Cross%20crate%20find%20usages%20seems%20to%20be%20broken%3F/near/229484749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Cross.20crate.20find.20usages.20seems.20to.20be.20broken.3F.html#229484749">(Mar 09 2021 at 14:26)</a>:</h4>
<p>I've noticed a couple of times that find usages stated to miss usages in other crates, is this something known?</p>



<a name="229484802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Cross%20crate%20find%20usages%20seems%20to%20be%20broken%3F/near/229484802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Cross.20crate.20find.20usages.20seems.20to.20be.20broken.3F.html#229484802">(Mar 09 2021 at 14:27)</a>:</h4>
<p>For example, if I search CompletionItem::score function, I don't see a usage in <a href="http://to_proto.rs">to_proto.rs</a></p>



<a name="229485428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Cross%20crate%20find%20usages%20seems%20to%20be%20broken%3F/near/229485428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Cross.20crate.20find.20usages.20seems.20to.20be.20broken.3F.html#229485428">(Mar 09 2021 at 14:31)</a>:</h4>
<p>ah, that's a different bug, we confuse function with a local var</p>



<a name="229489409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Cross%20crate%20find%20usages%20seems%20to%20be%20broken%3F/near/229489409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Cross.20crate.20find.20usages.20seems.20to.20be.20broken.3F.html#229489409">(Mar 09 2021 at 14:56)</a>:</h4>
<p>That misclassification is caused by macros again it seems</p>



<a name="229489588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Cross%20crate%20find%20usages%20seems%20to%20be%20broken%3F/near/229489588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Cross.20crate.20find.20usages.20seems.20to.20be.20broken.3F.html#229489588">(Mar 09 2021 at 14:57)</a>:</h4>
<p><a href="/user_uploads/4715/j1FNUzS1FcsCM1-DS0KUn16F/image.png">image.png</a> <br>
<a href="/user_uploads/4715/XIqesXFCkBLHLQr3SLcrSbH1/image.png">image.png</a><br>
Note how the color changes to blue which is callable in my theme</p>
<div class="message_inline_image"><a href="/user_uploads/4715/j1FNUzS1FcsCM1-DS0KUn16F/image.png" title="image.png"><img src="/user_uploads/4715/j1FNUzS1FcsCM1-DS0KUn16F/image.png"></a></div><div class="message_inline_image"><a href="/user_uploads/4715/XIqesXFCkBLHLQr3SLcrSbH1/image.png" title="image.png"><img src="/user_uploads/4715/XIqesXFCkBLHLQr3SLcrSbH1/image.png"></a></div>



<a name="229491100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Cross%20crate%20find%20usages%20seems%20to%20be%20broken%3F/near/229491100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Cross.20crate.20find.20usages.20seems.20to.20be.20broken.3F.html#229491100">(Mar 09 2021 at 15:07)</a>:</h4>
<p>Summoning <span class="user-mention" data-user-id="211727">@Jonas Schievink  [he/him]</span>  )</p>



<a name="229493795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Cross%20crate%20find%20usages%20seems%20to%20be%20broken%3F/near/229493795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Cross.20crate.20find.20usages.20seems.20to.20be.20broken.3F.html#229493795">(Mar 09 2021 at 15:24)</a>:</h4>
<p><em>sigh</em></p>



<a name="229493907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Cross%20crate%20find%20usages%20seems%20to%20be%20broken%3F/near/229493907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Cross.20crate.20find.20usages.20seems.20to.20be.20broken.3F.html#229493907">(Mar 09 2021 at 15:25)</a>:</h4>
<p>/me imagines a weary  <span class="user-mention silent" data-user-id="211727">Jonas Schievink  [he/him]</span> emerging from a column of smoke</p>



<a name="229495631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Cross%20crate%20find%20usages%20seems%20to%20be%20broken%3F/near/229495631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Cross.20crate.20find.20usages.20seems.20to.20be.20broken.3F.html#229495631">(Mar 09 2021 at 15:36)</a>:</h4>
<p>Seems like the problem is:</p>
<ul>
<li>Inner items have precedence over function argument patterns, but</li>
<li>Local variable bindings have precedence over inner items, and</li>
<li>We cannot express this properly, because resolving a name in a module scope will search all parent scopes as well</li>
</ul>
<p>The function in question will search the inner item scope for <code>completion_item2</code> and find the (outer) function, ignoring the function argument.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>